package com.itheima.web.listener;

import com.mysql.jdbc.AbandonedConnectionCleanupThread;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
// ServletContextListener 监视Web应用
@WebListener
@Slf4j
public class AppContextListener implements ServletContextListener {

    /**
     * 监听对象创建
     * @param sce
     */
    public void contextInitialized(ServletContextEvent sce) {
        String servletContextName = sce.getServletContext().getServletContextName();
        log.info("上下文监听:Web应用启动:{}",servletContextName);

    }

    /**
     * 监听销毁方法
     * @param sce
     */
    public void contextDestroyed(ServletContextEvent sce) {
        log.info("上下文监听:Web应用关闭....");
    }

}
